#include "tcl_mtk_dtv_tv.h"
TCL_MTK_DTV_TV::TCL_MTK_DTV_TV()
{

}



int TCL_MTK_DTV_TV::Read_Data(QDataStream &in)
{

    in>>ui4_ch_val
       >>ps_name
        >>ui2_tv
      >>ui2_isfav
      >>ui2_isskip;
    return 0;
}

int TCL_MTK_DTV_TV::Write_Data(QDataStream &out)
{
  out<<ui4_ch_val
     <<ps_name
     <<ui2_tv
     <<ui2_isfav
     <<ui2_isskip;

    return 0;
}


void TCL_MTK_DTV_TV::Set_Data(int order,QVariant value)
{
   bool *ok;
   *ok=false;
     switch(order)
     {

     case 0:
      ui4_ch_val=value.toUInt(ok);
      Q_ASSERT(*ok==true);
      break;
     case 1:
      ps_name=value.toString();
      break;
     case 2:
      ui2_tv=(ushort)value.toUInt(ok);
      Q_ASSERT(*ok==true);
      break;
     case 3:
         ui2_isfav=(ushort)value.toUInt(ok);
         Q_ASSERT(*ok==true);
         break;
      case 4:
         ui2_isskip=(ushort)value.toUInt(ok);
         Q_ASSERT(*ok==true);
         break;
     default:
      //qDebug("In MTK DTV set_Data:order error!");
         Q_ASSERT(order<5&&order>=0);

     }
}



int TCL_MTK_DTV_TV::Count_Item()
{
    return NUM_TV_ITEM;
}

QString TCL_MTK_DTV_TV::Get_Item(int i)
{
    Q_ASSERT(i>=0&&i<5);
    QString tmp;
    switch(i)
    {
        case 0:
         tmp.setNum(ui4_ch_val);
         break;
        case 1:
         tmp=ps_name;
         break;
        case 2:
            tmp.setNum(ui2_tv);
            break;
        case 3:
            tmp.setNum(ui2_isfav);
            break;
        case 4:
            tmp.setNum(ui2_isskip);
            break;

        default:
            tmp=" ";
            break;
    }
    return tmp;
}
\

void TCL_MTK_DTV_TV::Get_Data(QList<QString> *ch_data)
{
    QString tmp="";
    tmp.setNum(ui4_ch_val);
    ch_data->append(ps_name);
    tmp.setNum(ui2_tv);
    ch_data->append(tmp);
    tmp.setNum(ui2_isfav);
    ch_data->append(tmp);
    tmp.setNum(ui2_isskip);
     ch_data->append(tmp);
}


void TCL_MTK_DTV_TV::Set_Data(QList<QString> &ch_data)
{
    Q_ASSERT(ch_data.size()==5);
    bool *ok;
    *ok=false;
    ui4_ch_val=ch_data.at(0).toUInt(ok);
    Q_ASSERT(*ok==true);
    ps_name=ch_data.at(1);
    ui2_tv=ch_data.at(2).toUShort(ok);
    Q_ASSERT(*ok==true);
    ui2_isfav=ch_data.at(3).toUShort(ok);
    Q_ASSERT(*ok==true);
    ui2_isskip=ch_data.at(4).toUShort(ok);
    Q_ASSERT(*ok==true);


}
